package com.demo.java;

import com.demo.java.runa.StatePrinter;
import com.demo.java.runa.TestTimedWaiting;
import com.demo.java.runa.TestWaitingAndBlock;

import java.util.LinkedHashMap;
import java.util.Map;

public class Main {
    public static void main(String[] args) {

        Map<String,Thread> threadMap = new LinkedHashMap<>();

        // 状态输出
        Runnable runA = new StatePrinter(threadMap);
        threadMap.put("A",new Thread(runA,"A"));
        // TIMED_WAITING测试
        Runnable runB = new TestTimedWaiting(threadMap);
        threadMap.put("B",new Thread(runB,"B"));
        // WAITING和BLOCKED测试
        Runnable runC = new TestWaitingAndBlock(threadMap);
        threadMap.put("C",new Thread(runC,"C"));
        Runnable runD = new TestWaitingAndBlock(threadMap);
        threadMap.put("D",new Thread(runD,"D"));

        StatePrinter.print(threadMap);
        for(Thread thread:threadMap.values()){
            thread.start();
        }

    }
}
